﻿namespace MefContrib.Models.Provider
{
    using System;

    /// <summary>
    /// A default object factory which creates plain instances from the specified type, using
    /// the provided parameters to initialize the new instance.
    /// </summary>
    public class DefaultObjectFactory : ObjectFactory
    {
        /// <summary>
        /// Creates a new instance of the specifed type using the provided parameters.
        /// </summary>
        /// <param name="type">The type of the object to create.</param>
        /// <param name="parameters">An array of parameters to pass to object when it's being created.</param>
        /// <returns>A new object instance of the type specified by the <paramref name="type"/> parameter.</returns>
        public override object Create(Type type, params object[] parameters)
        {
            return Activator.CreateInstance(type, parameters);
        }
    }
}